package com.kermel.andromeda.data;

import android.test.AndroidTestCase;

public class TimeRemainingTest extends AndroidTestCase {

    protected void setUp() throws Exception {
        super.setUp();
    }

    protected void tearDown() throws Exception {
        super.tearDown();
    }
    
    public void testThatDecrementOneSecondTicksOffOneSecond() {
        TimeRemaining timeRemaining = new TimeRemaining(0, 0, 1);
        timeRemaining.decrementOneSecond();
        assertEquals(0, timeRemaining.getSeconds());
    }
    
    public void testThatDecrementOneSecondCorrectlyDecrementsMinuteWhenSecondsIsLessThanOrEqualToZero() {
        TimeRemaining timeRemaining = new TimeRemaining(0, 2);
        timeRemaining.decrementOneSecond();
        assertEquals(1, timeRemaining.getMinutes());
        
    }

    public void testThatDecrementOneSecondCorrectlyDecrementsHourWhenMinutesIsLessThanOrEqualToZero() {
        TimeRemaining timeRemaining = new TimeRemaining(2, 0, 0);
        timeRemaining.decrementOneSecond();
        assertEquals(1, timeRemaining.getHours());
    }
    
    public void testThatDecrementOneSecondRollsOverWhenMinutesIsGreaterThanZero() {
        TimeRemaining timeRemaining = new TimeRemaining(0, 2);
        
        timeRemaining.decrementOneSecond();
        assertEquals(1, timeRemaining.getMinutes());
        assertEquals(59, timeRemaining.getSeconds());
    }
    
    public void testThatToFormattedStringWorks() {
        TimeRemaining timeRemaining = new TimeRemaining(3, 2, 1);
        
        String result = timeRemaining.toFormattedString();
        assertNotNull(result);
        assertTrue(result.length() > 0);
    }
    
    public void testThatToFormattedStringReturnsOnlyMinutesAndSecondsWhenHoursEqualsZero() {
        TimeRemaining timeRemaining = new TimeRemaining(0, 2, 1);
        
        String result = timeRemaining.toFormattedString();
        assertNotNull(result);
        assertTrue(result.length() > 0);
        assertEquals(5, result.length());
    }
}
